package com.ruoyi.api.service.impl;

import com.ruoyi.api.service.HazardousAreasService;
import com.ruoyi.api.utils.ParseUtils;
import com.ruoyi.api.vo.Hazardous;
import com.ruoyi.api.vo.HazardousDemo;
import com.ruoyi.vim.mapper.HazardousAreasMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;


@Service

public class HazardousAreasServiceImpl implements HazardousAreasService {

    @Autowired
    private HazardousAreasMapper hazardousAreasMapper;


    /**
     * 判断是否进入危险区域
     * @param hazardous
     * @return
     */
    @Override
    public Object selectHazardous(Hazardous hazardous) {
        String geomLocation = ParseUtils.parseGeom(0,hazardous.getLocation());
        if(hazardous.getType() == 2){
            String geomRegion = ParseUtils.parseGeom(hazardous.getType(),hazardous.getRegion());
            boolean a = hazardousAreasMapper.selectHazardous(geomRegion,geomLocation);
            return a;
        }else {
            String geomRegion = ParseUtils.parseGeom(hazardous.getType(),hazardous.getRegion());
            boolean a = hazardousAreasMapper.selectHazardous(geomRegion,geomLocation);
            return a;
        }
    }

    /**
     * 添加
     * @param hazardousDemo
     */
    @Override
    public void add(HazardousDemo hazardousDemo) {
        hazardousAreasMapper.add(hazardousDemo);
    }


    @Override
    public String selectId(String userId) {
        return hazardousAreasMapper.selectId(Long.valueOf(userId));
    }

    @Override
    public void updateById(String id,String times) {
        hazardousAreasMapper.updatebyId(id,times);
    }

    @Override
    public Double stDistance(Double valueOf, Double valueOf1, Double valueOf2, Double valueOf3) {
        return hazardousAreasMapper.stDistance(valueOf,valueOf1,valueOf2,valueOf3);
    }

}
